#ifndef SCOPED_PTR_H
#define SCOPED_PTR_H

#include "base/macro_def.h"

template<typename Type>
class scoped_ptr {
  public:
    explicit scoped_ptr(Type* t = NULL)
        : t_(t) {
      enum {
        t = sizeof(Type)
      };
    }

    virtual ~scoped_ptr() {
      delete t_;
    }

    void reset(Type* n = NULL) {
      enum {
        t = sizeof(Type)
      };
      delete t_;
      t_ = n;
    }

    Type* get() const {
      return t_;
    }

    Type* release() {
      Type* tmp = t_;
      t_ = NULL;
      return tmp;
    }

    Type* operator->() {
      CHECK_NOTNULL(t_);
      return t_;
    }

    Type& operator*() {
      CHECK_NOTNULL(t_);
      return *t_;
    }

  private:
    Type* t_;

    DISALLOW_COPY_AND_ASSIGN(scoped_ptr);
};

#endif  // SCOPED_PTR_H
